package com.dtx.module.sqlmanager;

import com.dtx.entity.SysUser;
import com.dtx.utils.BeeTLUtils;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.SQLReady;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.page.DefaultPageRequest;
import org.beetl.sql.core.page.DefaultPageResult;
import org.beetl.sql.core.page.PageRequest;
import org.beetl.sql.core.page.PageResult;

import java.util.HashMap;

public class SQLMangerDemo01 {

    public static void main(String[] args) {
        SQLManager sqlManager = BeeTLUtils.getSQLManager();
        String sql = "select * from sys_user where department_id=?";
        PageRequest request = DefaultPageRequest.of(1,10);
        SQLReady sqlReady = new SQLReady(sql,new Object[]{1});
        PageResult pr = sqlManager.execute(sqlReady, SysUser.class,request);
        DefaultPageResult pageResult = (DefaultPageResult)pr;
        printPageResult(pageResult);

    }

    public  static void printPageResult(DefaultPageResult pageResult){
        System.out.println(pageResult.getPage());
        System.out.println(pageResult.getPageSize());
        System.out.println(pageResult.getTotalRow());
        System.out.println(pageResult.getTotalPage());
        System.out.println(pageResult.getList());
    }
}
